<?php
  
  /*
   * Validaiton for Document content
   */

  function documents_form_validation($form) {
	//print "<pre>";print_r($form); print "</pre>"; 
    $stat = new set_static_variable();
	
//check the corresponding concerned dept name
 //chk_concerned_dept($form['field_department']);
    // Duplication in title
    //check_title_duplication($form['title'], $form['type']['#value'], $form['field_department'], 'field_department', $stat->get_nid());
	
    $stat->set_nid(0);
	
	/*District Validation*/
   distvalidation($form['field_state']['und']['#value']);
   //print_r($dist_value); 

    // Bad character validations
    chkbadchar($form['title']['#value'], $form['title']['#title'], 'title');
	chkbadchar($form['field_dockeywords']['und'][0]['value'] ['#value'], $form['field_dockeywords']['und'][0]['value'] ['#title'], 'field_act_keyword'); 
	chkbadchar($form['field_docothers'][0]['value']['#value'],$form['field_docothers']['#title'], 'field_docothers'); 
	
	// Date validation
    //check_scheduler_date_expire($form['scheduler_settings']['unpublish_on']['date']['#value'],'unpublish_on');

	
	// minimum length charcter
  	minilength_validation($form['title']['#value'], 5, $form['title']['#title'], 'title');
	minilength_validation($form['field_dockeywords']['und'][0]['value']['#value'], 5, $form['field_dockeywords']['und'][0]['value']['#title'],'field_dockeywords');
  	//minilength_validation($form['field_dockeywords'][0]['value']['#value'], 5, $form['field_dockeywords']['#title'],'field_dockeywords');
  	
	// bad URL Check
	badurl($form['field_docurl'][0]['value']['#value'],$form['field_docurl']['#title'],'field_docurl');
	
    // Form type validation
    $form_type = $form['field_doctype'];
	//echo $form_type['value']['#value']; die;
	
	url_validation($form['field_docurl']['und'][0]['value']['#value']);

     if ($form['field_doctype']['und']['#value'] == 'download') { 
    // Validating the file size   
    //$field_obj = $form['field_act_file_upload']; 
	//$file_allowed_obj = $form_type;
	//print_r($form['field_act_file_upload']);
	//$filename = $form['field_act_file_upload']['und'][0]['#file']; 
	//$filename->filename;
    //file_upload_validation_D7($filename->filename,$form['field_doctype']['und']['#title']);  
  
  }
  
  //echo "sel".$form['field_doc_year']['und'][0]['value']['#value'];
 
   //Year
	check_integer_with_hypan($form['field_doc_year']['und'][0]['value']['#value'],$form['field_doc_year']['und'][0]['#title'],'field_doc_year');
	docu_year($form['field_doc_year']['und'][0]['value']['#value'],$form['field_doc_year']['und'][0]['#title'],'field_doc_year');
	//docu_year($form['field_doc_year'][0]['value']['#value'],$form['field_doc_year']['#title'],'field_doc_year');
	
 } // function documents_form_validation()

  function documents_presave_validation($node) {
    $reference_url = $node->field_docurl[0]['value'];
    $node->field_docurl[0]['value'] = url_validation($reference_url);
  } // function form_presave_validation()
